package com.coe3.datahandler;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

public class Image_Process {
	
	public static Bitmap getImageBitmap(String url) {
        Bitmap bm = null;
        try {
        	
        	BufferedInputStream bis = null;
        	InputStream is = null;
        	
        	while (bm == null) {
        		
        		URL aURL = new URL(url);
                URLConnection conn = aURL.openConnection();
                conn.connect();
				is = conn.getInputStream();
                bis = new BufferedInputStream(is);
                bm = BitmapFactory.decodeStream(bis);
			}//end while
        	
            //Bitmap to scaled to 10% original image.
//            bm = Bitmap.createScaledBitmap(bm, (bm.getWidth() * 10) / 100, (bm.getHeight() * 10) / 100, true);
        	
            bis.close();
            is.close();
       } catch (IOException e) {
    	   System.out.println(e.toString());
           Log.e("getImageBitmap", "Error getting bitmap" + e);
       }
       return bm;
    }

}
